//
//  NetWorkStatus.swift
//  SinaWeiBo
//
//  Created by Leon 笑 竹 on 2017/8/4.
//  Copyright © 2017年 Leon 笑 竹. All rights reserved.
//

import UIKit
import AFNetworking

class NetWorkStatus: NSObject {
    
    static let shared = NetWorkStatus()
    
    var statusStr = ""
    
    //实时监控网络状态
    func reachAbilityStatus() -> String{
        
        let reachAbilityManager = AFNetworkReachabilityManager.shared()
        
        reachAbilityManager.setReachabilityStatusChange { (status) in
            
            switch status {
                
            case .unknown:
                print("未知");
                self.statusStr = "未知"
                break
            case.reachableViaWiFi:
                print("wifi");
                self.statusStr = "WIFI"
                break
            case .reachableViaWWAN:
                print("4G");
                self.statusStr = "4g"
                break
            case.notReachable:
                print("无网络连接");
                self.statusStr = "无网络连接"
                break
            }
        }
        //开始检测
        reachAbilityManager.startMonitoring()
        return statusStr
    }
}
